package org.chen.wordwave.bean;

import android.util.Log;

import androidx.annotation.NonNull;

import org.litepal.annotation.Column;
import org.litepal.crud.LitePalSupport;

import java.io.Serializable;

public class Words extends LitePalSupport implements Serializable {
    @Column()
    private Integer id;
    private String english;
    private String chinese;
    private String symbol;
    private Integer image;
    private String imageUrl;
    private String prompt;

    public Words() {
    }

    public String getEnglish() {

        return english;
    }

    public void setEnglish(String english) {
        this.english = english;
    }

    public String getChinese() {
        return chinese;
    }

    public void setChinese(String chinese) {
        this.chinese = chinese;
    }

    public String getSymbol() {
        return symbol;
    }

    public void setSymbol(String symbol) {
        this.symbol = symbol;
    }

    public int getImage() {
        return image;
    }

    public void setImage(int image) {
        this.image = image;
    }

    public String getPrompt() {
        return prompt;
    }

    public void setPrompt(String prompt) {
        this.prompt = prompt;
    }

    @NonNull
    @Override
    public String toString() {
        return "Words{" +
                "id=" + id +
                ", english='" + english + '\'' +
                ", chinese='" + chinese + '\'' +
                ", symbol='" + symbol + '\'' +
                ", image=" + image +
                ", prompt='" + prompt + '\'' +
                '}';
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Words(String english, String chinese, String symbol, int image, String prompt) {

        this.english = english;
        this.chinese = chinese;
        this.imageUrl = null;
        this.symbol = symbol;
        this.image = image;
        this.prompt = prompt;

        // 添加调试日志
        Log.d("111w1w1w", "创建Words对象 - word: " + english + ", imageResource: " + image);
    }

    public Words(String english, String chinese, String symbol, String imageUrl, String prompt) {

        this.english = english;
        this.chinese = chinese;
        this.image = 0;
        this.symbol = symbol;
        this.imageUrl = imageUrl;
        this.prompt = prompt;
    }

    public String getImageUrl() {
        return imageUrl;
    }

    public void setImageUrl(String imageUrl) {
        this.imageUrl = imageUrl;
    }

    /**
     * 判断是否使用网络图片
     */
    public boolean isNetworkImage() {
        return imageUrl != null && !imageUrl.isEmpty();
    }

    /**
     * 获取图片显示源（优先网络图片）
     */
    public Object getImageSource() {
        if (isNetworkImage()) {
            return imageUrl;
        } else {
            return image;
        }
    }
}
